import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_getx/app/base/toast_widget.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

Future<void> toast(
  String? msg, {
  Duration time = const Duration(milliseconds: 1500),
  alignment = Alignment.center,
}) async {
  if (msg == null || msg.isEmpty) {
    return;
  }

  return SmartDialog.showToast(msg, time: time, widget: ToastWidget(msg: msg, alignment: alignment,));
}

Future<void> showLoading({
  String msg = 'loading...',
  Color background = Colors.black,
  bool clickBgDismissTemp = false,
  bool isLoadingTemp = true,
  bool? isPenetrateTemp,
  bool? isUseAnimationTemp,
  Duration? animationDurationTemp,
  Color? maskColorTemp,
  Widget? maskWidgetTemp,
  Widget? widget,
}) {
  return SmartDialog.showLoading(
    msg: msg,
    background: background,
    clickBgDismissTemp: clickBgDismissTemp,
    isLoadingTemp: isLoadingTemp,
    isPenetrateTemp: isPenetrateTemp,
    isUseAnimationTemp: isUseAnimationTemp,
    animationDurationTemp: animationDurationTemp,
    maskColorTemp: maskColorTemp,
    maskWidgetTemp: maskWidgetTemp,
    widget: widget,
  );
}


enum CloseType{
  OverlayLoading,
  Overlay,
  Toast,
  Loading,
  All,
}

void dismissSmart({CloseType closeType = CloseType.OverlayLoading}){
  SmartDialog.dismiss(closeType: closeType.index);
}
